package com.zw.a.basic.a02.demo04_if;

import java.util.Scanner;

//案例: if多分支之: 打印星期.
public class IfDemo04 {
    public static void main(String[] args) {
        //需求: 接收用户录入的数字[1, 7], 然后打印对应的星期.
        //1. 接收用户录入的数字.
        System.out.println("请录入一个数字: ");
        Scanner sc = new Scanner(System.in);
        int week = sc.nextInt();

        //2. 通过if. else if 实现判断用户录入的是星期几, 并打印结果.
        if (week == 1) {
            System.out.println("星期一");
        } else if (week == 2) {             //else的隐含条件是: week != 1
            System.out.println("星期二");
        } else if (week == 3) {             //else的隐含条件是: week != 1 && week != 2
            System.out.println("星期三");
        }else if (week == 4) {
            System.out.println("星期四");
        }else if (week == 5) {
            System.out.println("星期五");
        }else if (week == 6) {
            System.out.println("星期六");
        }else if (week == 7) {
            System.out.println("星期日");
        }else  {
            System.out.println("你是从火星来的吧, 地球没有这样的星期!");
        }
    }
}
